<?php
	include "common.php";
	error_reporting(0);
	session_start();
	if($_SESSION['logInCheck']!=1){
		header('Location: index.php?loginInfo=false');
	}
	$userLink = $_SESSION['userLink'];
	if($userLink!="hrpage.php"){
		echo "Sorry, You have no right to visit this page!!";
		exit;
	}
	$eid = $_SESSION['id'];
	$userFname = $_SESSION['userFname'];
	$userLname = $_SESSION['userLname'];
	$role = $_SESSION['role'];
	
	$userSql = "SELECT * FROM user WHERE e_id = '$eid'";
	$userSqlQuery = mysql_query($userSql);
	$userSqlResult = mysql_fetch_assoc($userSqlQuery);
	
	$email = $userSqlResult['email'];
	$notification = $userSqlResult['notification'];
	$timezone_offset = 6; // for getting local time offset hrs
	$systemDate = gmdate('y-m-d', time()+$timezone_offset*60*60);
	$compToday = strtotime($systemDate);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="index.css" type="text/css" />
<link rel="icon" type="image/ico" href="images/favicon.ico"></link> 
<link rel="shortcut icon" href="images/favicon.ico"></link>
<link rel="stylesheet" type="text/css" href="jquery.alerts.css" />
<script src="jquery.js" type="text/javascript"></script>
<script src="jquery-ui.js" type="text/javascript"></script>
<script src="jquery.ui.draggable" type="text/javascript"></script>
<script src="jquery.alerts.js" type="text/javascript"></script>
<script src="curvycorners.src.js" type="text/javascript"></script>
<script src="login.js" type="text/javascript"></script>
<title><?php echo "Welcome to ".$userFname." ".$userLname; ?></title>
</head>

<body>
<div class="main_div_other">
	<p><img src="images/creato_logo.jpg" /></p>
    <p id="creatobd">www.creatobd.com</p>
    <p id="date"><script>document.write(new_month+" "+new_date+", "+old_date.getFullYear()+" || "+new_day);</script></p>
    <div class="other_page_icons">
    	<div class="new_notification">
        	<img src="images/arrow_up.JPG" /><?php if ($notification >0){?><p>You have<?php echo " ".$notification." ";?>new notification</p><?php }?>
        </div><!--end of new_notification-->
    	<ul>
        	<a href="hrpage.php" class="active"><li><div id="home"></div><p>home</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="hr_employee.php"><li><div id="employee"></div><p>employee</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="hr_onduty.php"><li><div id="onduty"></div><p>on duty</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="hr_attendance.php"><li><div id="attendance"></div><p>attendance</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="hr_leave.php"><li><div id="leave"></div><p>leave</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="hr_notification.php"><li><div id="notification"></div><p>notification</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="hr_black_box_message.php"><li><div id="blackbox"></div><p>black box</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="#"><li><div id="hrpolicy"></div><p>hr policy</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="index.php"><li><div id="logout"></div><p>log out</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
        </ul>
    </div><!-- end of other_page_icons-->
    
</div><!-- end of main_div_other-->
<div class="othrpage_1">
	<p><a href="update_office_time.php">Update Office Time</a> | <a href="admchangepw.php">Change Password</a></p>
</div><!-- end of othrpage_1-->
<div class="page_content">	
	<?php
	
		//Warning
		$warningType = $userSqlResult['warning'];
		$checkSubmited = "SELECT * FROM reason_for_late WHERE e_id='$eid' and date='$systemDate'";
		$checkSubmitedQuery = mysql_query($checkSubmited);
		$checkSubmitedFetchArray = mysql_fetch_array($checkSubmitedQuery);
		$collectSubmitOrNotValue = $checkSubmitedFetchArray['submit'];
		$collectStatus = $checkSubmitedFetchArray['status'];
		if($warningType==1 && $collectSubmitOrNotValue==0){
				?>
				<script>
					jAlert('You are late, if you want to submit the reason, click <a href="hrlatereasonapprove.php" style="text-decoration:none; color:#00F; font-weight:bold;">Here</a>. After Submitting the reason this window will not be showed again.', 'Alert For Late Present');
				</script>
				<?php
			}
			else if($warningType==2 && $collectSubmitOrNotValue==0 && $collectStatus==0){
				$updateReasonForLateTable = "UPDATE reason_for_late SET status='1' WHERE e_id='$eid' and date='$systemDate'";
				$updateReasonForLateTableQuery = mysql_query($updateReasonForLateTable);
				?>
				<script>
					jAlert('Sorry, You are late three days and we have been deducted your one casual leave.');			
				</script>
				<?php
			}
			else if($warningType==3 && $collectSubmitOrNotValue==0 && $collectStatus==0){
				$updateReasonForLateTable = "UPDATE reason_for_late SET status='1' WHERE e_id='$eid' and date='$systemDate'";
				$updateReasonForLateTableQuery = mysql_query($updateReasonForLateTable);
				?>
				<script>
					jAlert('Sorry, You are late three days and your casual leave has been finished so we deducted your one earn leave');
				</script>
				<?php
			}
			$checkSubmit = $_GET['check'];
			if ($checkSubmit == 1)
			{
				$updateUserSql = "SELECT * FROM user WHERE e_id = '$eid'";
				$updateUserSqlQuery = mysql_query($updateUserSql);
				$userData = mysql_fetch_assoc($updateUserSqlQuery);
				?>
				<form action="get_up_user.php" method="post">
					<table cellpadding="0" cellspacing="0" class="apply4leave_table" style="margin:0 auto;">
						<tr valign="top">
							<td>Employee Id</td>
							<td><input type="text" value="<?php echo $userData['e_id'];?>" name="id" /></td>
						</tr>
						<tr valign="top">
							<td>Role</td>
							<td><input type="text" name="role" value="<?php echo $userData['role'];?>"/></td>
						</tr>
						<tr valign="top">
							<td>First Name</td>
							<td><input type="text" value="<?php echo $userData['f_name'];?>" name="fName" /></td>
						</tr>
						<tr>
							<td>Last name</td>
							<td><input type="text" value="<?php echo $userData['l_name'];?>" name="lName" /></td>
						</tr>
						<tr valign="top">
							<td>Email</td>
							<td><input type="text" name="email" value="<?php echo $userData['email'];?>"/></td>
						</tr>
						<tr valign="top">
							<td>Password</td>
							<td><input type="password" name="pass" value="<?php echo $userData['password'];?>"/></td>
						</tr>
						<tr valign="top">
							<td>Contact1</td>
							<td><input type="text" name="con1" value="<?php echo $userData['contact1'];?>"/></td>
						</tr>
						<tr valign="top">
							<td>Contact2</td>
							<td><input type="text" name="con2" value="<?php echo $userData['contact2'];?>" /></td>
						</tr>
						<tr valign="top">
							<td>Supervisor</td>
							<td><input type="text" name="super" value="<?php echo $userData['supervisor'];?>"/></td>
						</tr>
						<tr valign="top">
							<td>Address</td>
							<td><input type="text" name="add" value="<?php echo $userData['address'];?>"/></td>
						</tr>
						<tr valign="top">
							<td>Blood Group</td>
							<td><input type="text" name="blood" value="<?php echo $userData['blood_group'];?>"/></td>
						</tr>
						<tr valign="top">
							<td>Joining Date</td>
							<td><input type="text" name="j_date" value="<?php echo $userData['j_date'];?>"/></td>
							<td>(yyyy-mm-dd)</td>
						</tr>
						<tr valign="top">
							<td>Status</td>
							<td><input type="text" name="status" value="<?php echo $userData['status'];?>"/></td>
						</tr>
						<tr><td><input type="submit" value="Submit" /></td></tr>
					</table>
				</form>
		<?php 
			}
			else
			{			
				$userSql = "SELECT * FROM user WHERE e_id = '$eid'";
				$userSqlQuery = mysql_query($userSql);
				$data =  mysql_fetch_assoc($userSqlQuery);
				
				
		?>
			
				<table cellpadding="0" cellspacing="0" class="hrpage_info_table" align='center'>
					<tr><td colspan="3" style="background:#adacac; text-align:center; color:#FFF; font-size:14px;"><p>Welcome to <?php echo $data['f_name'] ?> <?php echo $data['l_name'] ?></p></td></tr>
					<tr valign="top">
						<td class="add_user_td1"><p>Employee Id </p></td>
						<td><p><?php echo $eid ?></p></td>
						<td style="width:10px; background:#eff2f6; padding:0px !important;">&nbsp;</td>
					</tr>
					<tr valign="top">
						<td class="add_user_td1"><p>Email </p></td>
						<td><p><?php echo $data['email'] ?></p></td>
						<td style="width:10px; background:#eff2f6; padding:0px !important;">&nbsp;</td>
					</tr>
					<tr valign="top">
						<td class="add_user_td1"><p>Supervisor </p></td>
						<td><p>Rashid Khan</p></td>
						<td style="width:10px; background:#eff2f6; padding:0px !important;">&nbsp;</td>
					</tr>
					<tr valign="top">
						<td class="add_user_td1"><p>Blood Group </p></td>
						<td><p><?php echo $data['blood_group']?></p></td>
						<td style="width:10px; background:#eff2f6; padding:0px !important;">&nbsp;</td>
					</tr>
					<tr valign="top">
						<td class="add_user_td1"><p>Address </p></td>
						<td><p><?php echo $data['address'] ?></p></td>
						<td style="width:10px; background:#eff2f6; padding:0px !important;">&nbsp;</td>
					</tr>
					<tr valign="top">
						<td class="add_user_td1"><p>Total Late in this Month </p></td>
						<td><p><?php echo $data['t_late']?></p></td>
						<td style="width:10px; background:#eff2f6; padding:0px !important;">&nbsp;</td>					
					</tr>					
				</table>			
			
			<?php 
			}
			
			
			
	?>
	
	
	
	
	
</div>

<div class="human_portal">
  		<p>creato human resourse portal</p>
</div><!-- end of human_portal-->


<script type="text/javascript">
	$(document).ready(function() {
	  notification_on(); 	
	  function notification_on()
	  {
	   	$('.new_notification').fadeIn(1);
	  }
	});
</script>

</body>
</html>